package com.liliudong.template.api.admin.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.DataPermissionInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.liliudong.template.api.admin.handler.SimpleDataPermissionHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * MybatisPlusAutoConfiguration
 *
 * @author ldli5
 * @classname MybatisPlusAutoConfiguration
 * @date 2024/6/17-16:36
 */
@Configuration
public class MybatisPlusConfiguration {

	@Bean
	public MybatisPlusInterceptor mybatisPlusInterceptor(SimpleDataPermissionHandler simpleDataPermissionHandler) {
		MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
		// 数据权限插件
		mybatisPlusInterceptor.addInnerInterceptor(new DataPermissionInterceptor(simpleDataPermissionHandler));
		mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor());
		return mybatisPlusInterceptor;
	}
}
